﻿using System.Configuration;

namespace SimpleWcf.Configuration
{
    /// <summary>
    /// A generic configuration element collection
    /// </summary>
    /// <typeparam name="T"></typeparam>
    [ConfigurationCollection(typeof(ConfigurationElement))]
    public class ConfigurationElementCollection<T> : ConfigurationElementCollection where T : ConfigurationElement, new()
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new T();
        }
        protected override object GetElementKey(ConfigurationElement element)
        {
            return element.ToString();
        }
        public T this[int idx]
        {
            get { return (T)BaseGet(idx); }
        }
    }
}